package com.ycsd.invest.order.business.listplugin;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.events.BeforeCreateListDataProviderArgs;
import kd.bos.form.events.HyperLinkClickArgs;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.mvc.list.ListDataProvider;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;

import java.util.List;

/**
 * 列表插件
 */
public class OrderInfoList extends AbstractListPlugin {

    @Override
    public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {
        //自定义数据构造器
        args.setListDataProvider(new ListDataProvider() {
            @Override
            public DynamicObjectCollection getData(int start, int limit) {
                DynamicObjectCollection data = super.getData(start, limit);
                for (DynamicObject dynamicObject : data) {
                    dynamicObject.set("order_remark", "我统一了一下备注");
                }
                return data;
            }
        });
    }

    @Override
    public void setFilter(SetFilterEvent e) {
        //数据过滤
        super.setFilter(e);
        List<QFilter> qFilters = e.getQFilters();
        qFilters.add(new QFilter("total_amount", QCP.equals, "9"));
    }

    @Override
    public void billListHyperLinkClick(HyperLinkClickArgs args) {
        //超连接点击
        args.setCancel(true);
        FormShowParameter showParameter = new FormShowParameter();
        // 设置子页面编码
        showParameter.setFormId("ycsd_order_info_up");
        // 子页面打开方式
        showParameter.getOpenStyle().setShowType(ShowType.Modal);
        // 打开子页面
        this.getView().showForm(showParameter);
    }


}
